package com.dragon.backstage.controller;

import com.dragon.backstage.domain.param.file.FileUploadParam;
import com.dragon.backstage.domain.vo.file.FileUploadVo;
import com.dragon.backstage.service.FileService;
import com.dragon.common.annotation.UserOperatorLog;
import com.dragon.common.enums.BusinessType;
import com.dragon.common.utils.AjaxResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 文件模块接口
 *
 * @author dragon
 * @version 1.0
 * @date 2024/8/9 16:19
 */
@RestController
@RequestMapping("/api/file")
@Tag(name = "文件模块接口")
public class FileController {

    @Resource
    private FileService fileService;


    /**
     * 上传文件
     *
     * @param param 添加菜单参数
     * @return 文件路径
     */
    @PostMapping("/upload")
    @Operation(summary = "上传文件")
    @UserOperatorLog(title = "文件管理", businessType = BusinessType.UPLOAD)
    public AjaxResult<FileUploadVo> upload(FileUploadParam param) {
        return fileService.uploadFile(param);
    }

}
